/*************************************************************************
    > File Name: atexit.c
    > Author:		
    > Mail:		
    > Created Time: 2021年03月25日 星期四 09时27分35秒
 ************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>


void exit_fun1(void)
{

	printf("at exit with hook fun1\n");
}
void exit_fun2(void)
{

	printf("at exit with hook fun2\n");
}

void onexit_fun1(int status, void *arg)
{

	printf("on exit with hook fun1, status:%d arg:%s\n", status, (char *)arg);
}
void onexit_fun2(int status, void *arg)
{

	printf("on exit with hook fun2, status:%d arg:%s\n", status, (char *)arg);
}


int main(int argc, char *argv[])
{

	on_exit(onexit_fun2, "test2");
	on_exit(onexit_fun1, "test1");

	atexit(exit_fun2);
	atexit(exit_fun1);

	exit(2);
	return 0;
}
